package com.xk._03真题骗._03栈_队列;

import java.util.Deque;
import java.util.LinkedList;

/*
 * @description: https://leetcode.cn/problems/min-stack/
 * @author: xu
 * @date: 2022/10/30 7:34
 */
public class _155最小栈1 {
    private Deque<Integer> stack = null; // 正常栈
    private Deque<Integer> minStack = null; // 最小栈

    public _155最小栈1() {
        stack = new LinkedList<>();
        minStack = new LinkedList<>();
        minStack.push(Integer.MAX_VALUE);
    }

    public void push(int val) {
        stack.push(val);
        minStack.push(Math.min(val, minStack.peek()));
    }

    public void pop() {
        stack.pop();
        minStack.pop();
    }

    public int top() {
        return stack.peek();
    }

    public int getMin() {
        return minStack.peek();
    }
}
